package com.socket;

import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;

public class ReadThread implements Runnable{
    private Socket socket;

    public ReadThread(Socket socket) {
        this.socket = socket;
    }


    @Override
    public void run() {
        try {
            while (true) {
                InputStream is = socket.getInputStream();
                byte[] bytes = new byte[1024];
                int len;
                while ((len = is.read(bytes)) > 0) {
                    System.out.println(new String(bytes,0,len));
                }

            }

        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
